<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="nested" uri="http://struts.apache.org/tags-nested" %>

<html>
<head>
    <title>MyITEA.com</title>
	<script type="text/javascript">
	
	//------------AJAX MODULE ---------------------------------------------------------------------
	var xmlHttp;
	
	function callDeleteBoard(){
	
		if(confirm("해당 사용자의 게시물을 삭제 하겠습니까?"))
		{
			startRequest();
		}
		return;
	}
	
	function startRequest() {	
	
		var cono = document.boardActionForm.cono.value;
		var tagetboard = document.boardActionForm.targetboardNm.value;
		var id = document.boardActionForm.searchId.options[document.boardActionForm.searchId.selectedIndex].value;
		var url = "board.do?method=delete&id="+id + "&cono="+cono+"&tagetbd="+tagetboard

		createXMLHttpRequest();
		//전송
	   	xmlHttp.open("GET", url, true);
   	  	xmlHttp.onreadystatechange = handleStateChange;
	    xmlHttp.send(null);
	}
	
	
	function createXMLHttpRequest() {
	    
	    if (window.ActiveXObject) {
	        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } 
	    else if (window.XMLHttpRequest) {
	        xmlHttp = new XMLHttpRequest();
	    }
	}
	
	function handleStateChange() {
	    if(xmlHttp.readyState == 4) {
	    
	    	if(xmlHttp.status == 200){
	    		parseResponse();	    		
			}	           
	    }
	}
	
	function parseResponse(){

		var xmlDoc = xmlHttp.responseXML;
		var objNode = xmlDoc.documentElement.firstChild;
		var result = objNode.text;
		
		if(result == 0)
		{
			alert("삭제 성공");
		}
	
		xmlHttp = null;
		//opener.parent.location.reload();
		//window.opener.document.location.href = window.opener.documentURL;
		//window.opener.document.location.href = window.opener.document.URL;
		
		self.close();
		window.opener.document.location.reload();
	}

	
	//------------AJAX MODULE ---------------------------------------------------------------------
	
</script>
</head>
<body style="margin: 0;font-family: sans-serif 돋움체;font-size: 10pt;">
<table style="width: 300px; height: 100px;border: 1px solid #666666;" cellpadding="0" cellspacing="0">
	<tr>
			<html:form action="/board.do" method="post">
		<td>
			
			<!-- 실제 컨텐츠 화면 표시부분---------------------------------------- -->
			<html:hidden property="cono"/>
			<html:hidden property="targetboardNm"/>
						
			<!--사용자별 게시물 관리-->
			<TABLE style="border: 1px solid #cccccc;" cellpadding="0" cellspacing="1">
				<TR>
				 	<TD colspan = "3" style="background: #eeeeee;text-align: center;font-weight: bold;height: 30px;"><bean:write name="boardActionForm" property="dispNm"/> 게시판 관리<TD>
			  	</TR>
			  	<logic:notEmpty name="boardActionForm" property="members">
			  		<TR>
				  		<TD style="width: 80px;text-align: center;height: 30px;">가입회원</TD>
				  		<TD colspan = "2" style="width: 220px;">
				  			
							
							<select name="searchId" style="font-size: 8pt;height: 20px;width: 150px;">
					  			
					  			<logic:iterate id="userinfo" name="boardActionForm" property="members" type="model.MemberCommunity">
					  				<option value='<bean:write name="userinfo" property="mid"/>'><bean:write name="userinfo" property="mid"/>(<bean:write name="userinfo" property="mcnick"/>)</option>
					      		</logic:iterate>	
					      	
					  		</select>
					  		
					  		
					  		<input type="button" value="삭제" onclick="javascript:callDeleteBoard()" style="background: #eeeeee;border: 1 solid #cccccc;height: 20px;"/>
				  		</TD>
					</TR>
			  	</logic:notEmpty>
			  	
			  	<logic:empty name="boardActionForm" property="members">
			  		<TR>
			  			<td colspan="2" style="width: 220px;">
			  				현재 가입자가 없습니다.
			  			</td>
			  		</TR>
			  	</logic:empty>
			</TABLE>
			<!-- ----------------------------------------------------------------- -->
		</td>
			</html:form>
	</tr>
</table>
</body>
</html>
